﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SeoWebSite.BLL;
using System.Data;
using System.Configuration;
using Newtonsoft.Json.Linq;

public class QoPreferences
{
    OS os = new OS();

    public string saveAppearance() {
        return "";
    }

    public string saveAutorun()
    {
        return "";
    }
    public string saveBackground()
    {
        return "";
    }
    public string saveQuickstart()
    {
        return "";
    }
    public string saveShortcut()
    {
        return "";
    }

    public string viewThemes() {
        QOThemesBLL themesbll = new QOThemesBLL();
        return null;
    }

    public string viewWallpapers()
    {
        QOWallpapersBLL wallpapersbll = new QOWallpapersBLL();
        DataSet ds = wallpapersbll.get_active();
        if (ds.Tables[0].Rows.Count <= 0)
        {
            return "{success: false, wallpapers: []}";
        }
        JArray items = new JArray();
        JObject item = new JObject();
        string wallpaper_dir = ConfigurationManager.AppSettings["WALLPAPERS_DIR"];
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            JObject wallpaper = JObject.Parse(dr["data"].ToString());
            item.Add("id", dr["id"].ToString());
            item.Add("group", (string)wallpaper["group"]);
            item.Add("name", (string)wallpaper["name"]);
            item.Add("thumbnail", wallpaper_dir + (string)wallpaper["thumbnail"]);
            item.Add("file", wallpaper_dir + (string)wallpaper["file"]);
            items.Add(item);
        }
        return "{success: true, wallpapers: " + items.ToString() + "}";
    }
}
